﻿--Synsets table constraints

ALTER TABLE [dbo].[Synsets]  WITH CHECK ADD  CONSTRAINT [FK_Synsets_Categories] FOREIGN KEY([CategoryId])
REFERENCES [dbo].[Categories] ([CategoryId])
GO
ALTER TABLE [dbo].[Synsets] CHECK CONSTRAINT [FK_Synsets_Categories]
GO
ALTER TABLE [dbo].[Synsets]  WITH CHECK ADD  CONSTRAINT [FK_Synsets_PartsOfSpeech] FOREIGN KEY([PosId])
REFERENCES [dbo].[PartsOfSpeech] ([PosId])
GO
ALTER TABLE [dbo].[Synsets] CHECK CONSTRAINT [FK_Synsets_PartsOfSpeech]
GO

--SenseSentenceAssociations table constraints

ALTER TABLE [dbo].[SenseSentenceAssociations]  WITH CHECK ADD  CONSTRAINT [FK_SenseSentenceAssociations_Senses] FOREIGN KEY([SenseId])
REFERENCES [dbo].[Senses] ([SenseId])
GO
ALTER TABLE [dbo].[SenseSentenceAssociations] CHECK CONSTRAINT [FK_SenseSentenceAssociations_Senses]
GO
ALTER TABLE [dbo].[SenseSentenceAssociations]  WITH CHECK ADD  CONSTRAINT [FK_SenseSentenceAssociations_Sentences] FOREIGN KEY([SentenceId])
REFERENCES [dbo].[Sentences] ([SentenceId])
GO
ALTER TABLE [dbo].[SenseSentenceAssociations] CHECK CONSTRAINT [FK_SenseSentenceAssociations_Sentences]
GO

--Senses table constraints

ALTER TABLE [dbo].[Senses]  WITH CHECK ADD  CONSTRAINT [FK_Senses_Synsets] FOREIGN KEY([SynsetId])
REFERENCES [dbo].[Synsets] ([SynsetId])
GO
ALTER TABLE [dbo].[Senses] CHECK CONSTRAINT [FK_Senses_Synsets]
GO
ALTER TABLE [dbo].[Senses]  WITH CHECK ADD  CONSTRAINT [FK_Senses_Words] FOREIGN KEY([WordId])
REFERENCES [dbo].[Words] ([WordId])
GO
ALTER TABLE [dbo].[Senses] CHECK CONSTRAINT [FK_Senses_Words]
GO

--RelationTypes table constraints

ALTER TABLE [dbo].[RelationTypes]  WITH CHECK ADD  CONSTRAINT [FK_RelationTypes_RelationTypes] FOREIGN KEY([Reflect])
REFERENCES [dbo].[RelationTypes] ([RelationTypeId])
GO
ALTER TABLE [dbo].[RelationTypes] CHECK CONSTRAINT [FK_RelationTypes_RelationTypes]
GO

--Relations table constraints

ALTER TABLE [dbo].[Relations]  WITH CHECK ADD  CONSTRAINT [FK_Relations_RelationTypes] FOREIGN KEY([TypeId])
REFERENCES [dbo].[RelationTypes] ([RelationTypeId])
GO
ALTER TABLE [dbo].[Relations] CHECK CONSTRAINT [FK_Relations_RelationTypes]
GO
ALTER TABLE [dbo].[Relations]  WITH CHECK ADD  CONSTRAINT [FK_Relations_Synsets] FOREIGN KEY([SourceSynsetId])
REFERENCES [dbo].[Synsets] ([SynsetId])
GO
ALTER TABLE [dbo].[Relations] CHECK CONSTRAINT [FK_Relations_Synsets]
GO
ALTER TABLE [dbo].[Relations]  WITH CHECK ADD  CONSTRAINT [FK_Relations_Synsets1] FOREIGN KEY([TargetSynsetId])
REFERENCES [dbo].[Synsets] ([SynsetId])
GO
ALTER TABLE [dbo].[Relations] CHECK CONSTRAINT [FK_Relations_Synsets1]
GO
ALTER TABLE [dbo].[Relations]  WITH CHECK ADD  CONSTRAINT [FK_Relations_Words] FOREIGN KEY([SourceWordId])
REFERENCES [dbo].[Words] ([WordId])
GO
ALTER TABLE [dbo].[Relations] CHECK CONSTRAINT [FK_Relations_Words]
GO
ALTER TABLE [dbo].[Relations]  WITH CHECK ADD  CONSTRAINT [FK_Relations_Words1] FOREIGN KEY([TargetWordId])
REFERENCES [dbo].[Words] ([WordId])
GO
ALTER TABLE [dbo].[Relations] CHECK CONSTRAINT [FK_Relations_Words1]
GO

--PartsOfSpeech table constraints

ALTER TABLE [dbo].[Categories]  WITH CHECK ADD  CONSTRAINT [FK_Categories_PartsOfSpeech] FOREIGN KEY([PosId])
REFERENCES [dbo].[PartsOfSpeech] ([PosId])
GO
ALTER TABLE [dbo].[Categories] CHECK CONSTRAINT [FK_Categories_PartsOfSpeech]
GO

--Exceptions table constraints

ALTER TABLE [dbo].[Exceptions]  WITH CHECK ADD  CONSTRAINT [FK_Exceptions_PartsOfSpeech] FOREIGN KEY([PosId])
REFERENCES [dbo].[PartsOfSpeech] ([PosId])
GO
ALTER TABLE [dbo].[Exceptions] CHECK CONSTRAINT [FK_Exceptions_PartsOfSpeech]
GO
ALTER TABLE [dbo].[Exceptions]  WITH CHECK ADD  CONSTRAINT [FK_Exceptions_Words] FOREIGN KEY([WordId])
REFERENCES [dbo].[Words] ([WordId])
GO
ALTER TABLE [dbo].[Exceptions] CHECK CONSTRAINT [FK_Exceptions_Words]
GO